//JavaScript Framework 2.0 Code
try {
	Type.registerNamespace('com.yonyou.ncmm_pac_pda.RefPageController');
	com.yonyou.ncmm_pac_pda.RefPageController = function() {
		com.yonyou.ncmm_pac_pda.RefPageController.initializeBase(this);
		this.initialize();
	}

	function com$yonyou$ncmm_pac_pda$RefPageController$initialize() {

	}

	function com$yonyou$ncmm_pac_pda$RefPageController$evaljs(js) {
		eval(js);
	}

	function docfilter_onchange(sender, args) {
		//		var billinfos = $ctx.getJSONArray("originalbillinfos");
		var keywords = $ctx.get("keywords");
		if(keywords == "") {
			NCMMDBDetailUtil.showDataList();
			return;
		}

		var wheresql = "where code like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + 
								"%' or name like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + "%'";
		NCMMDBDetailUtil.showDataList(wheresql);

	}

	//	function txtfilter_oninput(sender, args) {
	//		var billinfos = $ctx.getJSONArray("originalbillinfos");
	//		if(args.newvalue == "") {
	//			$ctx.put("bdlistdata", billinfos);
	//			$ctx.dataBind();
	//			return;
	//		}
	//		if(!billinfos || billinfos.length == 0) {
	//			return;
	//		}
	//		var billinfostmp = [];
	//		var len = billinfos.length;
	//		for(var idx = 0; idx < len; idx++) {
	//			var billinfo = $stringToJSON(billinfos[idx]);
	//
	//			if((billinfo["code"]).indexOf(args.newvalue) > -1 ||
	//				(billinfo["name"]).indexOf(args.newvalue) > -1) {
	//				billinfostmp.push(billinfo);
	//			}
	//		}
	//
	//		$ctx.put("bdlistdata", billinfostmp);
	//		$ctx.dataBind();
	//	}

	function onitemclick(sender, args) {
		var data = $id('listviewref').get('row');
//		$alert("listviewref row = " + data);

		$view.closeWithCallBack({
			"data": data
		});
	}

	function com$yonyou$ncmm_pac_pda$RefPageController$btnback_onclick(sender, args) {
		$view.close();
	}

	function onPageLoad(sender, args) {
		var param = $param.getJSONObject("data");
		param = $stringToJSON(param);
		if(param == null || param == "")
			return;

		param = $stringToJSON(param);
		$ctx.put("doctitle", param.reftitle);
		$ctx.dataBind();
		NCMMDBDetailUtil.apptablename = param["reftablename"];

		var wheresql = null;
		if(param["wheresql"] != null && param["wheresql"] != "") {
			wheresql = param["wheresql"];
		}

		NCMMDBDetailUtil.showDataList(wheresql);
		//		$ctx.put("originalbillinfos", $ctx.getJSONArray("bdlistdata"));
	}

	//列表下拉
	function listDownRefresh(sender, args) {
		var keywords = $ctx.get("keywords");
		if(keywords == "") {
			var ret = NCMMDBDetailUtil.listDown();
			if(ret)
				$id("listviewref").set("scrollto", "start");
			return;
		}

		var wheresql = "where code like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + 
								"%' or name like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + "%'";
		var ret = NCMMDBDetailUtil.listDown(wheresql);
		if(ret)
			$id("listviewref").set("scrollto", "start");
	}

	//列表上划
	function listUpRefresh(sender, args) {
		var keywords = $ctx.get("keywords");
		if(keywords == "") {
			NCMMDBDetailUtil.listUp();
			return;
		}

		var wheresql = "where code like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + 
								"%' or name like '%" + NCMMPubUtil.htmlspecialchars2UI(keywords) + "%'";
		NCMMDBDetailUtil.listUp(wheresql);

	}

	com.yonyou.ncmm_pac_pda.RefPageController.prototype = {
		btnback_onclick: com$yonyou$ncmm_pac_pda$RefPageController$btnback_onclick,
		initialize: com$yonyou$ncmm_pac_pda$RefPageController$initialize,
		evaljs: com$yonyou$ncmm_pac_pda$RefPageController$evaljs
	};
	com.yonyou.ncmm_pac_pda.RefPageController.registerClass('com.yonyou.ncmm_pac_pda.RefPageController', UMP.UI.Mvc.Controller);
} catch(e) {
	$e(e);
}